import java.io.RandomAccessFile;
import java.math.BigDecimal;




public class TTT {
	static byte result;
	public static void main(String[] args) {
		String n1="999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
		String n2="999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
		int d='.';
		long doubleToLongBits = Double.doubleToLongBits(1.1);
		BigDecimal bigDecimal1 = new BigDecimal(n1);
		BigDecimal bigDecimal2 = new BigDecimal(n2);
		
	    System.out.println(		bigDecimal1.add(bigDecimal2));
		System.out.println(add(n1,n2,10));
	/*	long currentTimeMillis = System.nanoTime();
		for (int i = 0; i < 1000; i++) {
			add(n1,n2,10);
		}
		long currentTimeMillis2 = System.nanoTime();
		for (int i = 0; i < 1000; i++) {
			
			BigDecimal bigDecimal1 = new BigDecimal(n1);
			BigDecimal bigDecimal2 = new BigDecimal(n2);
			bigDecimal1.add(bigDecimal2);
		//System.out.println(multiply(n1,n2,10));
		}
		long nanoTime = System.nanoTime();
		System.out.println( "1 "+(nanoTime-currentTimeMillis2));
		System.out.println( "2 "+(currentTimeMillis2-currentTimeMillis));*/
	
			
	
		
	}

	/**
	 * @param string2 
	 * @param string 
	 * @param radix 
	 * 
	 */
	public static String multiply(String string, String string2, int radix) {
		
		byte[] nums = split2Bytes(string, radix);
		byte[] nums2 = split2Bytes(string2, radix);
		byte[] t= new byte[nums.length+nums2.length];

		for (int i = 1; i < nums2.length + 1; i++) {
			for (int k = 0; k < nums.length; k++) {
				
				t[t.length - i-k]+= (nums[nums.length - k-1] * nums2[nums2.length - i]);
				int j = i+k;
				while (t[t.length - j] >= radix && t.length - j > 0) {
					t[t.length - j - 1] += (t[t.length - j]/radix);
					t[t.length - j] %=  radix;
					j++;
				}
			}
		}
		StringBuffer s = new StringBuffer();
		for (int i = 0; i < t.length; i++) {
			s.append(t[i]);
		}
		return s.toString();
		
	}
	/**
	 * @param string2 
	 * @param string 
	 * @param radix 
	 * 
	 */
	public static String add(String string, String string2, int radix) {

		byte[] nums = split2Bytes(string, radix);
		byte[] nums2 = split2Bytes(string2, radix);
		byte[] t;
		if (nums.length < nums2.length) {
			t = nums;
			nums = nums2;
			nums2 = t;
		}
		int length= nums2.length;
		for (int i = 1; i < nums2.length + 1; i++) {
			nums[nums.length - i] += nums2[nums2.length - i];
			int j = nums.length - i;
			while (nums[j] >= radix && j > 0) {
				nums[ j] -= radix;
				nums[ j - 1] += 1;
				j--;
			}
		}
		StringBuffer s = new StringBuffer();
		for (int i = 0; i < nums.length; i++) {
			s.append(nums[i]);
		}
		return s.toString();

	}
	/**
	 * @param subtrahend 
	 * @param minuend 
	 * @param radix 
	 * 
	 */
	public static String subtract(String minuend, String subtrahend, int radix) {
		String sign="";
		byte[] nums = split2Bytes(minuend, radix);
		byte[] nums2 = split2Bytes(subtrahend, radix);
		int lend=0;
		byte[] t;
		if (comparator(nums2, nums)) {
			t = nums;
			nums = nums2;
			nums2 = t;
			sign="-";
		}
		for (int i = 1; i < nums2.length + 1; i++) {
			int j = i;
			if(nums[nums.length - j] < nums2[nums2.length - j])
			while ( nums.length - j > 0) {
				nums[nums.length - j] += (radix-lend);
				j++;
				if(nums[nums.length - j ]>0){
					nums[nums.length - j ] -= 1;
					break;
				}
				lend=1;
			}
			nums[nums.length - i] -= nums2[nums2.length - i];
		}
		StringBuffer s = new StringBuffer();

		for (int i = 0; i < nums.length; i++) {
				s.append(nums[i]);
			
		}
		for (int i = 0;  s.length() >1; i++) {
			
			if(s.charAt(0)=='0')s.deleteCharAt(0);
			else break;
		}
		return sign+s.toString();

	}

	private static boolean comparator(byte[] nums, byte[] nums2) {
		if(nums.length > nums2.length)return true;
		if(nums.length < nums2.length)return false;
		for (int i = 0; i < nums2.length; i++) {
			if(nums[i] > nums2[i] )return true;
			if(nums[i] < nums2[i] )return false;
		}
		return false;
	}

	private static byte[] split2Bytes(String string, int radix) {
		if(string ==null)return new byte[]{0}; 
		//string=string.replaceAll(" ", "");
		byte[] nums =new byte[string.length()]; 
		for (int i = 0; i < nums.length; i++) {
			nums[i]=(byte) (string.charAt(i)-48);
		}
		return nums;
	}
	

}
